﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpDiary.Core.Data;

namespace SharpDiary.Core.ORMapping
{
    /// <summary>
    /// 插件类声明。
    /// </summary>
    [TableInfoAttribute("PlugIn")]
    public class PlugIn : DbMappingObjectBase
    {
        #region Fields & Properties

        private Int64 _id = -1;

        [FieldMapping(true, System.Data.DbType.Int64, true, true)]
        public Int64 Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _plugInId = string.Empty;

        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string PlugInId
        {
            get { return _plugInId; }
            set { _plugInId = value; }
        }

        private string _displayName = string.Empty;

        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string DisplayName
        {
            get { return _displayName; }
            set { _displayName = value; }
        }

        private string _assemblyName = string.Empty;

        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string AssemblyName
        {
            get { return _assemblyName; }
            set { _assemblyName = value; }
        }

        private string _mainClassFullName = string.Empty;

        [FieldMapping(false, System.Data.DbType.String, false, false)]
        public string MainClassFullName
        {
            get { return _mainClassFullName; }
            set { _mainClassFullName = value; }
        }

        private Int64 _validStatus = 0;

        [FieldMapping(false, System.Data.DbType.Int64, false, false)]
        public Int64 ValidStatus
        {
            get { return _validStatus; }
            set { _validStatus = value; }
        }

        #endregion

        #region Constructors

        public PlugIn() { }

        #endregion

        #region Methods

        /// <summary>
        /// 获取所有插件信息。
        /// </summary>
        /// <returns></returns>
        public static List<PlugIn> GetAllPlugIns()
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select * from PlugIn where ValidStatus = 1");

            return DbObjectMappingHelper.QueryObjectList<PlugIn>(sql.ToString());
        }

        #endregion
    }
}
